<?php
App::uses('AppModel', 'Model');
/**
 * Staffbook Model
 *
 */
class Staffbook extends AppModel {

/**
 * Use table
 *
 * @var mixed False or table name
 */

    //public $useTable = 'staffbook';

/**
 * Display field
 *
 * @var string
 */
//	public $displayField = 'title';


        public $primaryKey = 'id';
        
 public $validate = array(
		
		'title' => array( 
			'title_must_have_a_name' => array( 
			'rule' => array('notempty'), 
			'message' => 'Please enter a Title'), 
   	
   ),
     'content' => array( 
			'content_must_have_a_name' => array( 
			'rule' => array('notempty'), 
			'message' => 'Please enter Content'), 
     ),
     
          'active' => array( 
			'active_must_have_a_name' => array( 
			'rule' => array('notempty'), 
			'message' => 'Please enter Active'), 
     ),
 
   
     
     );
 
 
//      public $hasAndBelongsToMany = array(
//        'User' =>array(
//            'className' => 'User',
//            'jointTable' => 'users_staffbook',
//            'foreignKey' =>'user_id',
//            'associationForeignKey' => 'staffbook_id'
//         )  
//    );
       
function afterFind($results, $primary=false) 
	{ 
		foreach ($results as $key => $val) 
		{ 
			if (isset($val['Staffbook']['timestamp']))
			{ 
				$results[$key]['Staffbook']['timestamp'] = $this->dateFormatAfterFind($val['Staffbook']['timestamp']); 
				
			}
		} 
		return $results;
	} 	
	
	function dateFormatAfterFind($dateString) 
	{ 
		return date('d/m/Y h:m:s', strtotime($dateString)); 
	}
        
}

        
?>
